package com.lvyq.service.impl;

import com.lvyq.model.reply.ReplyMsg;
import com.lvyq.model.user.User;
import com.lvyq.repository.UserRepository;
import com.lvyq.service.ReplyMsgService;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @program: weg
 * @description:回复消息
 * @author: lvyq
 * @create: 2023-04-21 14:53
 **/

@Service
public class ReplyMsgServiceImpl implements ReplyMsgService {

    @Resource
    private UserRepository userRepository;

    @Resource
    private MongoTemplate mongoTemplate;

    @Override
    public void save(ReplyMsg replyMsg) {
        User user =userRepository.findByOpenId(replyMsg.getToUserName());
        replyMsg.setUserName(user.getNickName());
        mongoTemplate.save(replyMsg);
    }
}
